import { defineStore } from 'pinia';
import { getGradeList } from '@/api/member/level';
import { status } from 'nprogress';

export const useGradeStore = defineStore('grade', {
  state: () => ({
    gradeList: [] as any[],
    loaded: false,
  }),
  actions: {
    async fetchGradeList() {
      if (this.loaded) return;

      try {
        const res = await getGradeList({
          pageNum: 1,
          pageSize: 999,
          state: 1,
        });
        this.gradeList = res.rows;
        this.loaded = true;
      } catch (error) {
        console.error('获取等级列表失败:', error);
      }
    },
  },
});
